import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sensor.work.config.ClimaticExtremumConfig;
import com.sensor.work.config.DataBoundValueConfig;
import com.sensor.work.dto.DeviceDataDto;
import com.sensor.work.entity.ClimaticExtremum;
import com.sensor.work.entity.PudongDeviceConfig;
import com.sensor.work.entity.PudongDeviceData;


import com.sensor.work.entity.Threshold;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeanUtils;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.sensor.work.config.DataBoundValueConfig.isExceed;

public class Dome {

    @Test
    public void formatCheckTest() {
        Map<String, Object> message = new HashMap<>();
        message.put("deviceId", "666666666666");
        JSONObject jsonObject2 = new JSONObject();
        jsonObject2.set("ADSADA", "A");
        message.put("payload", jsonObject2);
        JSONObject jsonObject = JSONUtil.parseObj(message);
        Object deviceId = message.get("deviceId");

//        int size = pudongDeviceConfigService.list(new QueryWrapper<PudongDeviceConfig>().eq("device_no",deviceId)).size();
//        if (size==0){
//            log.warn(deviceId+"查无此设备");
//        }

        JSONObject payload = (JSONObject) jsonObject.get("payload");
        payload.set("deviceNo", deviceId);
//        System.out.println(payload instanceof DeviceDataDto);
//
        DeviceDataDto bean = payload.toBean(DeviceDataDto.class);
        PudongDeviceData pudongDeviceData = new PudongDeviceData();
        BeanUtils.copyProperties(bean, pudongDeviceData);
//            log.info("转换实体类数据{}",pudongDeviceData);
    }

    @Test
    public void 月份大小() {
        // 创建一个日历对象
        Calendar calendar = Calendar.getInstance();
        // 获取当前月份
        int month = calendar.get(Calendar.MONTH) + 1;
        System.out.println("当前月份是：" + month);

        ClimaticExtremumConfig.isExceed(60F,"AAA_A",1);

//        Map<List<String>, List<ClimaticExtremum>> dataBoundValueMap = ClimaticExtremumConfig.getDataBoundValueMap(month);
//        System.out.println(dataBoundValueMap);
//
//
//        String value = "1000";
//        for (List<String> list : dataBoundValueMap.keySet()) {
//
//
//            System.out.println("JIAN");
//            System.out.println(list);
//            List<ClimaticExtremum> climaticExtrema = dataBoundValueMap.get(list);
//            System.out.println("ZHI");
//            System.out.println(climaticExtrema);
//        }
//

    }

    @Test
    public void 大小对比() {

        System.out.println( "界限是否正常"+ isExceed(80.000001F,"AAA_A1"));

    }
}
